class ParseService {
    boolean transactional = true

    def serviceMethod() {
    }
    
    def buildActivity(String message){
    	def pattern = ~/([0-9]) miles ([0-9]+)/
    	
    	if (pattern.matcher(message).find(1)){
        	println "pattern found"
    	
    		def mattcher = message =~ pattern
    		def distanceString = mattcher[0][1]
    		def durationString = mattcher[0][2]
    	
        	def distanceVal = distanceString.toInteger()
        	def durationVal = distanceString.toInteger()
        	
    		def runInstance = new Run(distance:distanceVal, duration:durationVal)
    		//def runInstance = new Run(distance:1, duration:1)
        	println runInstance
    		return runInstance
    	}
    	
    	println "NOT found"
    	return Run(distance:0, duration:0);
    }

    
    def simpleEncoding = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
    def buildChartData(List runData){
    	    	
    	def chartData = ""
    	
    	for (i in runData) {
    		chartData = chartData + i.distance
    	}
    	
    	return chartData
    }

}
